import { userInfoIn, initUserInfo, stateUserIn} from '@/type/userInfo'
import $http from '@/request/http'

export default {
  namespaced: true,
  state: new initUserInfo(),
  getters: {},
  mutations: {
    setUserInfo(state: stateUserIn, val: userInfoIn) {
      state.userInfo = val
    },
  },
  actions: {
    async initUserInfo({ commit }: any) {
      const { data: info } = await $http.get('/api/employees/userinfo')
      commit('setUserInfo', info)
    },
    clearUserInfo({ commit }: any){
      commit('setUserInfo', {})
    }
  },
}
